<template>
  <el-collapse v-model="activeNames" class="drag-list">
    <div v-for="(item, index) in lists" :key="'drag_'+index" class="item">
      <input-normal v-if="listItemIsString" v-model="lists[index]" :label="'选项' + (index+1)" :placeholder="item.placeholder" class="input" @change="onUpdateItem(index)"></input-normal>
      <input-normal v-else v-model="item.text" :placeholder="item.placeholder" :label="'选项' + (index+1)" class="input" @change="onUpdateItem(index)"></input-normal>
      <i class="jy-icon-close" @click.stop="onDeleteItem(index)"></i>
    </div>
  </el-collapse>
</template>
<script>
import InputNormal from '@/views/components/edit/InputNormal.vue'

import { addUtils } from "@/views/js/add-utils"

export default {
  mixins: [addUtils],
  props: {
    lists: Array,
    onUpdateItem: Function,
    onDeleteItem: Function,
    comAttr: String,
  },
  components:{
    InputNormal,
  },
  computed: {
    listItemIsString(){
      return _.isString(this.lists[0])
    }
  },
};
</script>


